Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
How does Chrome (and other browsers) handle a “setTimeout” set to higher than 1000 milliseconds when a browser tab is hidden and inactive?

I’m debugging some login/logout issues on a site maintained by an outside vendor for a client and hopefully the title explains things, but more details are below.

As I understand it, any JavaScript running in a hidden tab in Chrome will alter the value of any setTimeout to be 1000 milliseconds to maintain overall system performance and not waste resources. As explained on this site:

“Browsers do exactly this. For inactive tabs, they automatically throttle timers to run every 1 second, regardless of the original delay specified in the code. For example, if the code originally used setInterval() to run some code every 50 ms, once the application is moved to a background tab, the interval automatically becomes 1000 ms (1 second).”

That definitely makes sense in the case of a setTimeout value that is set lower than 1,000 milliseconds like 50 milliseconds and such. But what about values higher than 1,000 milliseconds?

Will Chrome set the setTimeout value to 1,000 milliseconds even though 900,000 milliseconds (aka: 900 seconds, aka: 15 minutes) is clearly higher than that?

Here is a chunk of code from the vendor’s web page I believe is causing issues I am attempting to assist in debugging. It doesn’t do its job when it is in a hidden tab.

function keepSessionAlive() {
    if (externalAdminWindow && externalAdminWindow.closed) {
        externalAdminWindow = null;
    }
    if (externalFGWindow && externalFGWindow.closed) {
        externalFGWindow = null;
    }
    if (externalAdminWindow || externalFGWindow) {
        $find("ctl00_RadAjaxManager1").ajaxRequest("KeepAlive");
        setTimeout(function() {
            keepSessionAlive();
        }, 900000);
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Most browsers throttle timeouts in inactive tabs. It means that all setTimeout's will have a minimum of 1000ms timeout. Everything longer than that should work as expected. So, answering your question, 15min timeout should not be affected.

Check out setTimeout's Timeouts in inactive tabs section on MDN: https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#timeouts_in_inactive_tabs

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda